<?php
namespace app\admin\controller;

class AjaxUploads extends \think\Controller
{
	public function uploads($exts=['jpg','gif','png','jpeg','zip','rar','doc','docx'], $rule='create_once_flag'){
		 if (empty($_FILES))
             return;
         $upload = new \org\Upload();
         $upload->maxSize  = 3145728 ;
         $upload->saveRule = $rule;
         $upload->allowExts  = $exts;
         $upload->savePath = "public/uploads/";
         if(false == $info = $upload->uploadOne($_FILES['file'])) 
             return;
         return json_encode($info[0]);
    } 

	public function img(){
        return $this->uploads(['jpg', 'gif', 'png', 'jpeg']);
    } 

	public function file(){
        return $this->uploads(['zip','rar','doc','docx','pdf'], '');
    } 
} 
